<?php
/*

  Copyright 2005  Blackhacker (email : bh@blackhacker.net)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

INSTRUCTIONS
============

Add the following code to your template where you want your tags to appear:

<?php the_bunny_tags(); ?>

The keywords will appear as links wrapped in <p class="tags">Tags: ...</p>. You may want to add CSS to style the list.

If you want other html, you can try things like the following (thanks, Scott):

<?php the_bunny_tags("<ul><li>", "</li></ul>", "</li><li>"); ?>

If you want keywords to be translated as tags for posts which do not have tags defined, change the setting below. Attention! your keyword list must be stored in a custom field 'keywords' and be a comma-separated list -- otherwise you will need to edit the



 function get_bunny_tags_list().

WARNING: if your pages aren't utf-8 and you use non-ascii characters in your tags, your tags might not get indexed properly.

*/


/*
CHANGELOG
=========
0.1  - Initial release 03.30.2006

CREDITS
=======

*/

require_once('bh-widgets/BH_Widget_Base.php');

class BH_Tag_Cloud_Widget extends BH_Widget_Base {

	function widget($args){
		extract($args);

		$smallest = $this->get_attribute('smallest');
		$smallest = $smallest ? $smallest : 10;
		$largest = $this->get_attribute('largest');
		$largest = $largest ? $largest : 64;
		$limit = $this->get_attribute('limit');
		$limit = $limit ? $limit : 25;
		$min_freq =  $this->get_attribute('min_freq');
		$limit = $limit ? $limit : 3;


		echo "$before_widget\n";
		echo $this->get_widget_start_tag($args);
		
		BH_Tags::cloud($smallest, $largest, '', ' ', $min_freq, $limit);

		echo $this->get_widget_end_tag($args);
		echo $after_widget;
	}

	function control() {
	
		$smallest = $this->get_attribute('smallest');
		$smallest = $smallest ? $smallest : 10;
		$largest = $this->get_attribute('largest');
		$largest = $largest ? $largest : 32;
		$limit = $this->get_attribute('limit');
		$limit = $limit ? $limit : 25;
		$min_freq =  $this->get_attribute('min_freq');
		$limit = $limit ? $limit : 3;

		if($this->get_request_param('submit') ) {
		
			$smallest = $this->get_request_param('smallest');
			$largest = $this->get_request_param('largest');
		
			$limit = $this->get_request_param('limit');
			$min_freq = $this->get_request_param('min_freq');
			
			$this->set_attribute('smallest', $smallest);
			$this->set_attribute('largest', $largest);
			
			$this->set_attribute('limit', $limit);
			$this->set_attribute('min_freq', $min_freq);
		}
		
		
		
		echo '<label>Font Range</label>';
		echo '<input type="text" id="'.$this->get_request_param_name('smallest') .'" name="'.$this->get_request_param_name('smallest') .'" value="'. $smallest .'" size="2" maxlength="2"/> - ';
		echo '<input type="text" id="'.$this->get_request_param_name('largest') .'" name="'.$this->get_request_param_name('largest') .'" value="'. $largest .'" size="2" maxlength="2" /><br/>'. "\n";


		echo '<label>Limit</label>';
		echo '<input type="text" id="'.$this->get_request_param_name('limit') .'" name="'.$this->get_request_param_name('limit') .'" value="'. $limit .'" size="2" maxlength="2"/><br/>'. "\n";

		echo '<label>Min Frequency</label>';
		echo '<input type="text" id="'.$this->get_request_param_name('min_freq') .'" name="'.$this->get_request_param_name('min_freq') .'" value="'. $min_freq .'" size="2" maxlength="2"/><br/>'. "\n";
		
		
		echo '<input type="hidden" name="'.$this->get_request_param_name('submit').'" value="submit" />'. "\n";
	}
}

bh_widgets_register_class('BH_Tag_Cloud_Widget');

?>
